﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>用户登录</title>
    <link rel="stylesheet" href="static/css/css_1.css" />
    <link rel="stylesheet" href="static/css/fontello_1.css">
    <!--[if IE 7]><link rel="stylesheet" href="static/css/fontello-ie7_1.css"><![endif]-->
    <link rel="stylesheet" type="text/css" href="static/css/jquery.fancybox_1.css" media="screen" />
    <link rel="stylesheet" href="static/css/wuxie_1.css" />
</head>
<body style="background: #fff;">
<form action="/Member/Login?msg=%E6%9C%AA%E7%99%BB%E5%BD%95" method="post"><input name="__RequestVerificationToken" type="hidden" value="yskn6a0qjW8G0KIyHnL4iHvvQbVy_NbqizI8Z4OB-n3rL4u9I2hoXp8NOBpw4YIMlFqE2gCQpoT_hsIRLCYjrKAoRyrkmA5WdiWRZpiaZTs1" />    <div class="login_view bgwh" style=" width: 500px; margin: 150px auto 0;">
        <div class="login login_info" id="data">
            <h2 class="f28 n tc">用户登录</h2>
            <span class="login_error db f14 tc"><span class="field-validation-valid" data-valmsg-for="UserName" data-valmsg-replace="true"></span></span>
            <ul>
                <li><input type="text" class="txt br2" name="UserName" id="UserName" value="" size="35" placeholder="手机号"><i class="icon-user-male abs" title="请输入登录账号"></i></li>
                <li>
                    <input type="password" class="txt br2" name="Password" id="Password" value="" size="35" placeholder="验证码" style="width: 126px;">
                    <i class="icon-key abs" title="请输入验证码"></i>
                    <input class="login_btn btn bgorange br2 abs mt5 ml10" id="Button1" type="button" value="获取验证码" style="width: 112px;">
                </li>
            </ul>
            <div class="login_action"><input class="login_btn btn bggr br2 wp100" id="Button" type="button" value="登录"></div>
        </div>
    </div>
</form>    <script type="text/javascript" src="static/js/jquery-1.8.2.min_1.js"></script>
    <script type="text/javascript" src="static/js/jquery.validate.min.js"></script>
    <script type="text/javascript" src="static/js/jquery.validate.unobtrusive.min.js"></script>

    <script>
        String.prototype.IsMobile = function () {
            return /^0{0,1}1[3,4,5,7,8][0-9]{9}$/.test(this);
        }
        var timer;
        var secs = 60;
        function Timer() {
            secs--;
            $("#Button1").val(secs + "秒后重送");
            if (secs == 0) {
                secs = 60;
                window.clearInterval(timer);//清楚定时任务
                $("#Button1").attr("disabled", false);
                $("#Button1").val("获取验证码");
            }
        }

        $(document).ready(function () {

            $("#UserName").bind("blur", function () {
                if ($(this).val() == "") {
                    $(".login_error").html("请输入登录账号");
                } else {
                    $(".login_error").html("");
                }
            });
            $("#Password").bind("blur", function () {
                if ($(this).val() == "") {
                    $(".login_error").html("请输入密码");
                } else {
                    $(".login_error").html("");
                }
            });
            $("#Button1").bind("click", function () {
                if ($("#UserName").val() == "") {
                    alert("请输入手机号码");
                    $("#UserName").focus();
                    return false;
                }
                if (!$("#UserName").val().IsMobile()) {
                    alert("请输入正确手机号码");
                    $("#UserName").focus();
                    return false;
                }
                $("#Button1").attr("disabled", true).val("获取中...");

                $.ajax({
                    type: 'post',
                    url: 'SendMobilePassword',
                    data: 'Mobile=' + $("#UserName").val(),
                    timeout: 60000,
                    success: function (res) {
                        if (res.Success) {
                            timer = window.setInterval("Timer()", 1000);//启用定时倒计
                        } else {
                            $("#Button1").attr("disabled", false).val("获取验证码");
                        }
                        alert(res.ErrorMessages);
                    },
                    error: function () {
                        $("#Button1").attr("disabled", false).val("获取验证码");
                        alert('连接服务器错误，请稍后再试！');
                    }
                });
            });
            $("#Button").bind("click", function () {
                if ($("#UserName").val() == "") {
                    $(".login_error").html("请输入登录账号");
                    return false;
                }
                if ($("#Password").val() == "") {
                    $(".login_error").html("请输入密码");
                    return false;
                }
                $("#Button").val("登录中...").unbind("click");
                $("form").submit();
            });
        });
    </script>
</body>
</html>